<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  
  <body>
    <p>hello <span id="p1" name="pro">wo<span>rl</span>d</span></p>
  </body>
  
  <script>
    /* innerHTML 获取不包含标签的标签内的HTML内容 */
    console.log(document.getElementById('p1').innerHTML);//wo<span>rl</span>d
    /* innerText 获取不包含标签的标签内的文本内容 */
    console.log(document.getElementById('p1').innerText);//world
    /* outerHTML 获取包含标签的标签内的HTML内容 */
    console.log(document.getElementById('p1').outerHTML);//<span id="p1" name="pro">wo<span>rl</span>d</span>
    /* outerText 获取包含标签的标签内的文本内容 */
    console.log(document.getElementById('p1').outerText);//world
  </script>
</html>